Implement basic card-based interception combat system#10
Conversation
xbito
commented
Jul 7, 2025
- Defines BattleState and integrates it into GameState.
- Adds InterceptConfirmationModal to initiate battles from WorldMap UFO clicks.
- Implements BattleScreen UI with displays for vehicle/UFO status, player hand, and battle controls.
- Implements card mechanics: deck setup, shuffling, drawing (including reshuffling discard), playing cards with energy costs.
- Basic damage card effects and win/loss conditions are in place.
- Rudimentary turn loop: player turn (play cards, end turn) -> basic UFO attack -> player draws card and refreshes energy.
- Adds unit tests for card utility functions (shuffle, draw).
- Defines BattleState and integrates it into GameState. - Adds InterceptConfirmationModal to initiate battles from WorldMap UFO clicks. - Implements BattleScreen UI with displays for vehicle/UFO status, player hand, and battle controls. - Implements card mechanics: deck setup, shuffling, drawing (including reshuffling discard), playing cards with energy costs. - Basic damage card effects and win/loss conditions are in place. - Rudimentary turn loop: player turn (play cards, end turn) -> basic UFO attack -> player draws card and refreshes energy. - Adds unit tests for card utility functions (shuffle, draw).
There was a problem hiding this comment.
Pull Request Overview
This PR adds a basic card-based combat system triggered by intercepting UFOs, including data definitions, utility functions, UI components, and integration into the main app.
- Adds new battle-related fields to the global game state (
activeBattle, selected entities). - Overhauls card definitions with helper factories, consolidates into
ALL_CARDS, and provides deck utilities with tests. - Introduces
InterceptConfirmationModalandBattleScreencomponents, and hooks up battle initiation, card play, and turn flow inApp.tsx.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Added activeBattle, selectedVehicleForBattle, selectedUFOForBattle to GameState. |
| src/data/cards.ts | Refactored card arrays using createEffect/createRequirement, consolidated into ALL_CARDS, and added getStarterDeck, shuffleDeck, and drawCards functions. |
| src/data/tests/cards.test.ts | Added unit tests for deck shuffling, drawing, and starter deck generation. |
| src/components/InterceptConfirmationModal.tsx | New modal component for choosing an interceptor before battle. |
| src/components/BattleScreen.tsx | New battle UI showing statuses, hand, and controls. |
| src/App.tsx | Integrated the interception/battle flow: state setup, handlers for playing cards and ending turns. |
Comments suppressed due to low confidence (1)
src/types.ts:316
- [nitpick] The new
activeBattle,selectedVehicleForBattle, andselectedUFOForBattlefields lack comments. Consider adding docstrings to explain their expected usage and lifecycle.
activeBattle?: BattleState | null;
| newPlayerDiscard = drawResult.newDiscardPile; | ||
|
|
||
| // Replenish player energy (example: vehicle's energyPerTurn) | ||
| const playerMaxEnergy = prev.activeBattle.vehicleStatus.maxEnergy || 3; |
There was a problem hiding this comment.
This resets energy to maxEnergy each turn rather than using energyPerTurn. If intended, document it; otherwise, use vehicleStatus.energyPerTurn to refill energy.
| break; | ||
| } | ||
| // Reshuffle discard pile into deck | ||
| console.log("Reshuffling discard pile into deck."); |
There was a problem hiding this comment.
Per logging guidelines, include a stage prefix, timestamp, and colorized output rather than a plain console.log. For example, use a helper that prepends [DRAW] [HH:MM:SS] and styles the message.
| )} | ||
|
|
||
| <div className="flex justify-end space-x-3"> | ||
| <button |
There was a problem hiding this comment.
To follow the project's UI guidelines, add a relevant icon from lucide-react to the 'Launch Interceptor' and 'Cancel' buttons for better affordance.
| const [currentTurnTransactions, setCurrentTurnTransactions] = useState<number>(0); | ||
|
|
||
|
|
||
| const handleInitiateBattle = useCallback((vehicle: Vehicle, ufo: UFO) => { |
There was a problem hiding this comment.
This handler contains heavy battle-initialization logic. Consider extracting deck setup and initial BattleState construction into separate utility modules to keep App.tsx lean and maintainable.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>